﻿namespace Middleware
{
    //使用 MiddlewareFactory 激活的中间件
    public class FactoryActivatedMiddleware : IMiddleware
    {
        public FactoryActivatedMiddleware() { }

        public async Task InvokeAsync(HttpContext context, RequestDelegate next)
        {
            var keyValue = context.Request.Query["key"];

            if (!string.IsNullOrWhiteSpace(keyValue))
            {
                await context.Response.WriteAsync($"Output: key—{keyValue}");
            }

            await next(context);
        }
    }
}
